package cn.edu.nju.software.connector1Imp;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

import cn.edu.nju.software.connector1.AgentToSellerPOA;


public class AgentToSellerImp extends 	AgentToSellerPOA{
	/*
	 * Agent notify the seller that the seller can send the Goods to the buyer
	 */
	@Override
	public void notifySellerSendGood(String buyID) {
//		?
//		?
//		?
//		?
//		?
		System.out.println("Seller has sent good. The transaction's ID is " + buyID);
	}

	/*
	 * Agent notify the seller that the accounts transfer is successful
	 */
	@Override
	public void transferSuccess(String buyID) {	
		try {
			Class.forName("com.mysql.jdbc.Driver");
			Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "NICAIA");
			Statement statement = conn.createStatement(); 
			String sql = "update transactionslist set State='1' where TransactionID='" + buyID + "'";
			statement.executeUpdate(sql);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		System.out.println("Transfer success " + buyID);
	}

}
